<template>
  <div class="enterprise-info">
    <div class="title">{{info.name}}</div>
    <div class="top">
      <div class="header">企业信息</div>
      <div class="content">
        <div class="desc" v-html="info.showContent"></div>
        <div class="img-box">
          <img class="photo" :src="info.showPicUrl" alt="enterprise">
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="tabs">
        <div
          :class="['tab-item', curr === i ? 'active' : '']"
          v-for="(t, i) in tabs"
          :key="i"
          @click="curr = i"
        >{{ t }}</div>
      </div>
      <CompLdrk v-show="curr === 0" :info="info.floatingPopulation"></CompLdrk>
      <CompSsmz v-show="curr === 1" :info="info.ethnicMinorityList"></CompSsmz>
      <CompQzf v-show="curr === 2" :info="info.groupHousingList"></CompQzf>
      <CompTsrq v-show="curr === 3" :info="info.specialgroupsList"></CompTsrq>
    </div>
  </div>
</template>

<script>
import CompLdrk from './CompLdrk'
import CompSsmz from './CompSsmz'
import CompQzf from './CompQzf'
import CompTsrq from './CompTsrq'
import api from '@/api'
export default {
  name: "index",
  components: {
    CompLdrk,
    CompSsmz,
    CompQzf,
    CompTsrq
  },
  props: {
    id: {
      type: [String, Number],
      default: ''
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      tabs: ['流动人口', '企业少数民族', '群租房信息', '特殊人群'],
      curr: 0,
      info: {}
    }
  },
  watch: {
    visible: {
      immediate: true,
      handler(val) {
        if (val) {
          this.curr = 0
          this.queryEnterpriseInfo()
        } else {
          this.info = {}
        }
      }
    }
  },
  methods: {
    async queryEnterpriseInfo() {
      let {code, data} = await api.DP_ENTERPRISE_INFO({
        id: this.id
      })
      if (code === 0) {
        this.info = data
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .enterprise-info {
    height: 812px;
    background: url("../../../../assets/dp-imgs/bg-dialog@2x.png") no-repeat;
    background-size: 100% 100%;
    position: relative;
    padding: 0 38px;
    .title {
      font-size: 20px;
      font-weight: bold;
      color: #18F9C6;
      width: 270px;
      text-align: center;
      position: absolute;
      top: -10px;
      left: calc(50% + 8px);
      transform: translateX(-50%);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .top {
      padding-top: 35px;
      padding-bottom: 28px;
      .header {
        font-size: 20px;
        font-weight: bold;
        color: #3E94FF;
        padding-left: 28px;
        position: relative;
        &::before {
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          width: 20px;
          height: 15px;
          display: block;
          content: "";
          background: url(../../../../assets/dp-imgs/icon-title@2x.png) no-repeat;
          background-size: 100% 100%;
        }
      }
      .content {
        display: flex;
        padding-top: 22px;
        ::v-deep .desc {
          width: 739px;
          height: 193px;
          padding-right: 10px;
          margin-right: 16px;
          font-size: 16px;
          font-weight: 400;
          color: #FFFFFF;
          line-height: 40px;
          overflow-y: auto;
          p {
            margin: 0;
            text-indent: 32px;
          }
        }
        .img-box {
          width: 495px;
          height: 208px;
          overflow: hidden;
          position: relative;
          .photo {
            width: 100%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
          }
        }
      }
    }
    .bottom {
      .tabs {
        display: flex;
        margin-bottom: 22px;
        .tab-item {
          margin-right: 15px;
          height: 30px;
          line-height: 29px;
          box-sizing: border-box;
          padding: 0 20px;
          font-size: 20px;
          font-weight: bold;
          color: rgba(62, 148, 255, 0.5);
          background: url("../../../../assets/dp-imgs/border-btn@2x.png") no-repeat;
          background-size: 100% 100%;
          cursor: pointer;
          &.active {
            background: url("../../../../assets/dp-imgs/border-btn2@2x.png") no-repeat;
            background-size: 100% 100%;
            color: #3E94FF;
          }
        }
      }
    }
  }
  ::v-deep .table {
    color: #fff;
    background-color: transparent;
    &::before {
      height: 0;
    }
    thead, th, tr, td {
      color: #fff;
      background-color: transparent;
      border-bottom: none;
    }
    th {
      background: #14164E;
      font-size: 16px;
      font-weight: 400;
    }
    td {
      font-size: 16px;
      font-weight: 400;
      padding: 24px 0;
    }
  }
</style>
